package io.renren.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.SeatEslEntity;
import io.renren.service.SeatEslService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 工位价签
 *
 * @author 1
 * @email 1@2.com
 * @date 2021-11-19 11:03:23
 */
@RestController
@RequestMapping("/seatesl")
public class SeatEslController {
    @Autowired
    private SeatEslService seatEslService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions(":seatesl:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = seatEslService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions(":seatesl:info")
    public R info(@PathVariable("id") Long id){
        SeatEslEntity seatEsl = seatEslService.getById(id);

        return R.ok().put("seatEsl", seatEsl);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions(":seatesl:save")
    public R save(@RequestBody SeatEslEntity seatEsl){
        seatEslService.saveOrUpdate(seatEsl);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions(":seatesl:update")
    public R update(@RequestBody SeatEslEntity seatEsl){
        ValidatorUtils.validateEntity(seatEsl);
        seatEslService.updateById(seatEsl);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions(":seatesl:delete")
    public R delete(@RequestBody Long[] ids){
        seatEslService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
